package kom;

import java.util.concurrent.Semaphore;
import java.util.logging.Level;
import java.util.logging.Logger;

// ASYNC cooldown but takes it on another thread for measuring time
// its just a lightweight imprecise timer so we can have loads of timers
// with no lag with this, bu its highly imprecise
public class Cooldown {

    public Cooldown(int tempo) {
        this.time = tempo;
        Thread novoCoolDown = new Thread(cooldown);
        novoCoolDown.start();
    }
    private int time;
    private boolean finished = false;
    Runnable cooldown = new Runnable() {
        public void run() {
            try {
                Thread.sleep(time);
                finished = true;
            } catch (InterruptedException ex) {
                Logger.getLogger(Cooldown.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    };

    public boolean hasFinished() {
        return this.finished;
    }
}
